layui.use(['table', 'admin', 'ax', 'func'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var func = layui.func;
    var form = layui.form;
    var layer = layui.layer;
    /**
     * 服务详情管理
     */
    var TableDetails = {
        tableId: "TableDetails"
    };

    /**
     * 初始化表格的列
     */
    TableDetails.initColumn = function () {
        return [[
            {type: 'numbers', title: '序号', width: 100},
            {field: 'COLUMN_NAME', sort: false, title: '字段名称', align: "center"},
            {field: 'IS_NULLABLE', sort: false, title: '是否为空', align: "center"},
            {field: 'DATA_TYPE', sort: false, title: '字段类型', align: "center"},
            {field: 'COLUMN_COMMENT', sort: false, title: '字段注释', align: "center"},
        ]];
    };

    var ajax = new $ax(Feng.ctxPath + "/databaseListKh/detail?id=" + Feng.getUrlParam("serviceId"));
    var result = ajax.start();
    console.log(result)
    $("#id").val(result.data.id);
    $("#standard").html(result.data.standard);
    $("#system").html(result.data.system);
    $("#details").html(result.data.details);
    $("#tableName").html(Feng.getUrlParam("tableName"))
    if (result.data.servicetype == '1') {
        $("#servicetype").text('数据库服务')
    }

    //点击返回按钮
    $("#returnBefore").click(function () {
        history.go(-1)
    })


    // 渲染表格
    var tableResult = table.render({
        elem: '#' + TableDetails.tableId,
        url: Feng.ctxPath + '/dbServicedetails/getTableDetails?dbName=' + result.data.dbName + '&dbNumber=' + result.data.dbNumber + '&dbUrl=' + result.data.dbUrl + '&dbType=' + result.data.dbType + '&username=' + result.data.username + '&password=' + result.data.password + '&tableName=' + Feng.getUrlParam("tableName"),
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        skin: "line",
        cols: TableDetails.initColumn(),
        done: function () {
            $('tr').css('background-color', '#ffffff');
        }
    });

});
